package com.college.util;

import javax.servlet.http.HttpServletRequest;

/**
 * 判断当前请求是否是ajax请求
 */

public class CrowdUtil {
    public static boolean judgeRequestType(HttpServletRequest request){
        String acceptHeadler = request.getHeader("Accept");
        String xRequestHeader = request.getHeader("X-Reqeusted-With");
        if (acceptHeadler != null && acceptHeadler.contains("application/json") ||
            xRequestHeader!=null && xRequestHeader.equals("XMLHTTPRequest")){
            return true;
        }
        return false;
    }
}
